<?php

	class DeleteMediaCommand implements ICommand
	{
		public function execute($event)
		{
			$id = $event->data['id'];
			
			EbModel::getModel('Media','Media')->delete($id);
			
			$mediaitems = EbModel::getModel('Media','MediaItem')->selectByMedia($id);
			
			foreach ($mediaitems AS $mediaitem)
			{
				EbModel::getModel('Media','MediaItem')->delete($mediaitem->mi_id);	
			}
			
			return new Event('redirect',EbController::$request->referer);
		}
	}